Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit urllib3 version to < 2 because it breaks internetarchive/session.py #615

Closed
wants to merge 1 commit into from

Conversation

vbanos
Copy link

@vbanos vbanos commented Nov 2, 2023

See the error we get in production when we use urllib3 2.x

Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]: Traceback (most recent call last):
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:   File "/opt/liveweb/lib/python3.8/site-packages/spn_uploader/processors.py", line 121, in mark_uploaded
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:     item = ia.get_item(upload_item)
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:   File "/opt/liveweb/lib/python3.8/site-packages/internetarchive/api.py", line 115, in get_item
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:     archive_session = get_session(config, config_file, debug, http_adapter_kwargs)
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:   File "/opt/liveweb/lib/python3.8/site-packages/internetarchive/api.py", line 75, in get_session
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:     return session.ArchiveSession(config, config_file, debug, http_adapter_kwargs)
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:   File "/opt/liveweb/lib/python3.8/site-packages/internetarchive/session.py", line 110, in __init__
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:     self.mount_http_adapter()
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:   File "/opt/liveweb/lib/python3.8/site-packages/internetarchive/session.py", line 162, in mount_http_adapter
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]:     method_whitelist=Retry.DEFAULT_METHOD_WHITELIST,
Oct 31 01:40:13 wwwb-spn26.us.archive.org instawayback_uploader.py[49361]: AttributeError: type object 'Retry' has no attribute 'DEFAULT_METHOD_WHITELIST'

Limit `urllib3` to < 2 because it breaks `internetarchive/session.py`
@jjjake
Copy link
Owner

jjjake commented Nov 6, 2023

@vbanos do you have any more details on this change? What version of urllib3 did you get this error message in? The latest version of urllib3.Retry seems to have the DEFAULT_ALLOWED_METHODS attribute as far as I can tell:

In [6]: import urllib3

In [7]: urllib3.Retry.DEFAULT_ALLOWED_METHODS
Out[7]: frozenset({'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE'})

In [8]: urllib3.__version__
Out[8]: '2.0.7'

At any rate, we should update session.py to support newer versions of urllib3 (e.g. using whatever new attribute or function they have for this, or just adding our own hard-coded list of allowed methods) rather than pinning an older version. I'm happy to make that change if you don't have time. Thanks for the report and contribution!

@vbanos
Copy link
Author

vbanos commented Nov 7, 2023

The error was about DEFAULT_METHOD_WHITELIST and not DEFAULT_ALLOWED_METHODS

AttributeError: type object 'Retry' has no attribute 'DEFAULT_METHOD_WHITELIST'

I was using urllib3 2.0.7.
I'm sorry but I don't have time to fix it, please do it when you can, its not super-critical for us.
Thank you.

@vbanos vbanos closed this Nov 7, 2023
@jjjake
Copy link
Owner

jjjake commented Nov 7, 2023

Ah, thanks for catching that @vbanos. Looks like my confusion was caused by this change already being committed in 2021 (ef20f844).

I believe v2.2.0 is the first version with this patch. You should be set after upgrading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants